package com.t235.gc.goods.service.impl;

import com.t235.gc.dao.GoodsCategoryDao;
import com.t235.gc.entity.GoodsCategory;
import com.t235.gc.goods.service.GoodsCategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商品分类表(GoodsCategory)表服务实现类
 *
 * @author makejava
 * @since 2021-03-24 08:45:32
 */
@Service("goodsCategoryService")
public class GoodsCategoryServiceImpl implements GoodsCategoryService {
    @Resource
    private GoodsCategoryDao goodsCategoryDao;

    /**
     * 通过ID查询单条数据
     *
     * @param goodscategoryid 主键
     * @return 实例对象
     */
    @Override
    public GoodsCategory queryById(Long goodscategoryid) {
        return this.goodsCategoryDao.queryById(goodscategoryid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GoodsCategory> queryAllByLimit(int offset, int limit) {
        return this.goodsCategoryDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param goodsCategory 实例对象
     * @return 实例对象
     */
    @Override
    public GoodsCategory insert(GoodsCategory goodsCategory) {
        this.goodsCategoryDao.insert(goodsCategory);
        return goodsCategory;
    }

    /**
     * 修改数据
     *
     * @param goodsCategory 实例对象
     * @return 实例对象
     */
    @Override
    public GoodsCategory update(GoodsCategory goodsCategory) {
        this.goodsCategoryDao.update(goodsCategory);
        return this.queryById(goodsCategory.getGoodscategoryid());
    }

    /**
     * 通过主键删除数据
     *
     * @param goodscategoryid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long goodscategoryid) {
        return this.goodsCategoryDao.deleteById(goodscategoryid) > 0;
    }
}
